package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.ShangPinType;
import com.gxa.pojo.ZhiChuType;
import com.gxa.service.shezhiservice.KeHuType46Service;
import com.gxa.service.shezhiservice.ZhiChuType46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Author x
 */
@RestController
@RequestMapping("/ZhiChuType")
@Api(value = "支付类别管理" , tags = "支付类别数据接口API")
@RequiresPermissions("支出类别")
public class ZhiChuTypeController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
    public ZhiChuType46Service zhiChuType46Service;

    @GetMapping("/selectAllZhiChuTypeForPage")
    @ApiOperation(value = "支出查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectAllZhiChuTypeForPage(@RequestParam int page,@RequestParam int size)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);
//        return r;
        return zhiChuType46Service.selectAllZhiChuTypeForPage( page , size);

    }
    @GetMapping("/selectZhiChuTypeByType")
    @ApiOperation(value = "支出查询接口（根据条件查询）",notes="提供当前页码与每页显示条数，支出类别",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "zhiChuType",value = "支出类别",required = false,dataType = "int",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectZhiChuTypeByType(@RequestParam int page,@RequestParam int size,String zhiChuType)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ZhiChuType zhiChuType = new ZhiChuType();
//        zhiChuType.setId(666);
//        list.add(zhiChuType);
//        r.setData(list);
//        return r;
        return zhiChuType46Service.selectZhiChuTypeByType(page ,size ,zhiChuType);
    }
    @PostMapping("/insertZhiChuType")
    @ApiOperation(value = "新增支出接口",notes="提供支出信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertZhiChuType(@RequestBody ZhiChuType zhiChu)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ZhiChuType zhiChuType = new ZhiChuType();
//        zhiChuType.setId(6666);
//        list.add(zhiChuType);
//        r.setData(list);
//        return r;
        return zhiChuType46Service.insertZhiChuType(zhiChu);
    }

    @PostMapping("/updateZhiChuTypeById")
    @ApiOperation(value = "修改支出信息接口",notes="提供支出信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateZhiChuTypeById(@RequestBody ZhiChuType zhiChu)
    {
//        r.setCode(200);
//        r.setMsg("修改成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ZhiChuType zhiChuType = new ZhiChuType();
//        zhiChuType.setId(6656);
//        list.add(zhiChuType);
//        r.setData(list);
//        return r;
        return zhiChuType46Service.updateZhiChuTypeById(zhiChu);
    }

    @PostMapping("/deleteZhiChuTypeById")
    @ApiOperation(value = "删除支出接口",notes = "提供支出id",httpMethod = "post",response = R.class)
    @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteZhiChuTypeById(@RequestParam int id)
    {
//        r.setCode(200);
//        r.setMsg("删除成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ZhiChuType zhiChuType = new ZhiChuType();
//        zhiChuType.setId(6636);
//        list.add(zhiChuType);
//        r.setData(list);
//        return r;
        return zhiChuType46Service.deleteZhiChuTypeById(id);
    }


}
